using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using VOL.Entity.DomainModels;
using VOL.demo.IRepositories;

namespace VOL.demo.Services
{
    public partial class PurchaseOrderItemModelService
    {
        /// <summary>
        /// 根据进货单号获取明细列表
        /// </summary>
        /// <param name="orderCode">进货单号</param>
        /// <returns>明细列表</returns>
        public async Task<List<PurchaseOrderItemModel>> GetItemsByOrderCodeAsync(string orderCode)
        {
            return await repository.GetItemsByOrderCodeAsync(orderCode);
        }

        /// <summary>
        /// 根据进货单号获取明细列表（连表查询，返回DTO）
        /// </summary>
        /// <param name="orderCode">进货单号</param>
        /// <returns>包含关联数据的DTO列表</returns>
        public async Task<List<PurchaseOrderItemDto>> GetItemsWithJoinByOrderCodeAsync(string orderCode)
        {
            return await repository.GetItemsWithJoinByOrderCodeAsync(orderCode);
        }

        /// <summary>
        /// 批量添加进货明细
        /// </summary>
        /// <param name="items">明细列表</param>
        /// <returns>是否成功</returns>
        public async Task<bool> AddItemsAsync(List<PurchaseOrderItemModel> items)
        {
            return await repository.AddItemsAsync(items);
        }

        /// <summary>
        /// 根据进货单号删除明细
        /// </summary>
        /// <param name="orderCode">进货单号</param>
        /// <returns>是否成功</returns>
        public async Task<bool> DeleteItemsByOrderCodeAsync(string orderCode)
        {
            return await repository.DeleteItemsByOrderCodeAsync(orderCode);
        }

        /// <summary>
        /// 更新明细项
        /// </summary>
        /// <param name="item">明细项</param>
        /// <returns>是否成功</returns>
        public async Task<bool> UpdateItemAsync(PurchaseOrderItemModel item)
        {
            return await repository.UpdateItemAsync(item);
        }
    }
}
